﻿@using DNT.RavenQA.Web.Infrastructure.Extensions

@model AddQuestionViewModel

<div id="mainbar">
    @using (Html.BeginForm())
    {
        <fieldset class="form-item">
            @if (Model.ErrorMessage.IsNotNullOrEmpty())
            {
                <div class="error">
                    @Model.ErrorMessage
                </div>
            }

            @Html.ValidationSummary(true)
            @Html.AntiForgeryToken()
            <div>
                @Html.LabelFor(model => model.Input.Title)
                @Html.EditorFor(model => model.Input.Title)
                <div class="cbt"></div>
            </div>
            <div>
                @Html.TextAreaFor(model => model.Input.Body, new { @class = "mdd_editor" })
            </div>
            <div>
                @Html.LabelFor(model => model.TagsSearchKey)
                @Html.EditorFor(model => model.TagsSearchKey)
                @Html.EditorFor(model => model.Input.TagList)
            </div>
            <p></p>
            <div id="tagManagerContainer"></div>
            <p></p>
            <p>
                <input type="submit" value="Post your question" />
            </p>
        </fieldset>
    }
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/tag-manager")
    @Styles.Render("~/content/themes/base/css")
    @Scripts.Render("~/bundles/markdowndeep")
    @Styles.Render("~/content/markdowndeep")

    <script type="text/javascript">
        $(function ()
        {
            var el = '@Html.ClientIdFor(m => m.TagsSearchKey)';
            var hidden = '@Html.ClientIdFor(m => m.Input.TagList)';

            $.tagManager($('#' + el),
                {
                    containerSelector: '#tagManagerContainer',
                    hiddenFieldSelector: '#' + hidden
                });

            $('textarea.mdd_editor').MarkdownDeep(
                {
                    ExtraMode: true,
                    resizebar: false,
                    SafeMode: true,
                    help_location: '/Content/markdown/mdd_help.htm'
                });
        });
    </script>
}